﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Manager.master" AutoEventWireup="true" CodeFile="MailBox.aspx.cs" Inherits="User_MailBox" EnableEventValidation="true" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <style>
        .HeaderText
        {
            color: #0577B6;
            font-weight: bold;
        }
    </style>
    <script type="text/javascript">
        var redirect = function () {
            var postback = this.postback.fn
            postback();
            return false;
        }
      </script>
    <div style="margin:0 auto">
        <div class="content_area1">
            <h1>Hộp thư đến</h1>
            <div style="margin-left:20px;">
                <div style="width:648px">
                    <ext:Panel runat="server" Border="False">
                        <Buttons>
                            <ext:Button ID="btnReply" runat="server" Text="Soạn thư mới" OnClick="ComposeMail" AutoPostBack="true" FormBind="true">
                                <Listeners>
                                    <Click Fn="redirect" Handler="App.direct.ComposeMail();" />
                                </Listeners>
                            </ext:Button>
                        </Buttons>
                    </ext:Panel>
                </div>
                <asp:GridView ID="grvInbox" runat="server" AutoGenerateColumns="false" OnPageIndexChanging="grvInbox_PageIndexChanging" 
                    AllowPaging="true" PageSize="20" Width="97%" CssClass="tableStyle" OnRowCommand="grvInbox_RowCommand">
                    <Columns>
                        <asp:TemplateField ItemStyle-Width="35%" ItemStyle-HorizontalAlign="Left" HeaderText="Tiêu đề">
                            <ItemTemplate>
                                <a href='<%# String.Format(MailDetail("{0}"),Eval("Id")) %>'><%# Eval("Subject")%></a>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Center" HeaderText="Người gửi">
                            <ItemTemplate>
                                <%# Eval("UserEmail")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Ngày nhận">
                            <ItemTemplate>
                                <%# Eval("ReceiveDate","{0:d}") %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Tùy chọn">
                            <ItemTemplate>
                                <asp:ImageButton ID="btndelete" runat="server" ImageUrl="~/images/Delete.png" CommandName="deleteInbox" 
                                    CommandArgument='<%#Eval("Id") %>' OnClientClick="return confirm('Bạn có chắc muốn xóa không ?');" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <b>No Email here</b>
                    </EmptyDataTemplate>
                    <PagerSettings PageButtonCount="50" Position="Bottom" />
                </asp:GridView>
            </div>            
            <br class="clear" />
            <img src="<%= ResolveUrl("~/images/bottom.jpg")%>" align="absbottom" alt="" />
        </div>
        <div class="content_area1">
            <h1>Hộp thư đi</h1>
            <div style="margin-left:20px;">
                <asp:GridView ID="grvOutbox" runat="server" AutoGenerateColumns="false" OnPageIndexChanging="grvInbox_PageIndexChanging" 
                    AllowPaging="true" PageSize="20" Width="97%" CssClass="tableStyle" OnRowCommand="grvOutbox_RowCommand">
                    <Columns>
                        <asp:TemplateField ItemStyle-Width="35%" ItemStyle-HorizontalAlign="Left" HeaderText="Tiêu đề">
                            <ItemTemplate>
                                <a href='<%# String.Format(MailDetail("{0}"),Eval("Id")) %>'><%# DataBinder.Eval(Container.DataItem, "Subject")%></a>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Center" HeaderText="Người nhận">
                            <ItemTemplate>
                                <%# DataBinder.Eval(Container.DataItem, "UserEmail")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Ngày gửi">
                            <ItemTemplate>
                                <%# Eval("CreateDate", "{0:d}")%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center" HeaderText="Tùy chọn">
                            <ItemTemplate>
                                <asp:ImageButton ID="btndelete" runat="server" ImageUrl="~/images/Delete.png" CommandName="deleteOutbox" 
                                    CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Id") %>' OnClientClick="return confirm('Bạn có chắc muốn xóa không ?');" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <b>No Email here</b>
                    </EmptyDataTemplate>
                    <PagerSettings PageButtonCount="50" Position="TopAndBottom" />
                </asp:GridView>
            </div>
            <br class="clear" />
            <img src="<%= ResolveUrl("~/images/bottom.jpg")%>" align="absbottom" alt="" />
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>

